
// lib
// config
// script & methods & public
import logUtils from "utils/logUtils";
// store
import { state } from "./state";
// service

import toast from "components/toast";
import { ReqBorrowPage } from "biz/Borrow/api";
import { cancelOrderService, getOrderPageService } from "biz/Borrow/service";
// interface
// 其它

// 借阅记录分页列表
export async function getOrderPage() {
  const sp = state.getSearch();
  logUtils.info("搜索参数", sp);
  const params: ReqBorrowPage = {
    ...sp,
    pageNum: state.page,
    pageSize: state.size,
  };
  // // 调用服务
  state.loading = true;
  const result = await getOrderPageService(params);
  state.loading = false;
  // 成功
  if (result.payload) {
    state.total = result.payload.total;
    state.list = result.payload.list;
  }
}

// 订单管理-基本信息
export async function cancelOrder(id: number) {
  state.loading = true;
  const result = await cancelOrderService({
    id,
  });
  state.loading = false;
  // 成功
  if (result.payload) {
    // state.detail = result.payload;
    toast.success("取消成功")
    getOrderPage()
  }
}


export async function didMount() {
  getOrderPage();
}
